import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

const router = new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'layout',
      component: () => import("../views/layout.vue"),
      children: [
        {
          path: '',
          name: 'index',
          component: () => import("../views/index/index.vue"),
        },
        {
          path: 'about',
          name: 'about',
          component: () => import("../views/about/about.vue"),
        },
        {
          path: 'changelog',
          name: 'changelog',
          component: () => import("../views/changelog/changelog.vue"),
        },
        {
          path: 'company',
          name: 'company',
          component: () => import("../views/company/company.vue"),
        },
        {
          path: 'contact',
          name: 'contact',
          component: () => import("../views/contact/contact.vue"),
        },
        {
          path: 'ecommerce',
          name: 'ecommerce',
          component: () => import("../views/ecommerce/ecommerce.vue"),
        },
        {
          path: 'frequently',
          name: 'frequently',
          component: () => import("../views/frequently/frequently.vue"),
        },
        {
          path: 'join',
          name: 'join',
          component: () => import("../views/join/join.vue"),
        },
        {
          path: 'partners',
          name: 'partners',
          component: () => import("../views/partners/partners.vue"),
        },
        {
          path: 'support',
          name: 'support',
          component: () => import("../views/support/support.vue"),
        },
        {
          path: 'tutorial',
          name: 'tutorial',
          component: () => import("../views/tutorial/tutorial.vue"),
        },
        {
          path: 'service',
          name: 'service',
          component: () => import("../views/service/service.vue"),
        },
        {
          path: 'education',
          name: 'education',
          component: () => import("../views/education/education.vue"),
        },
        {
          path: 'restaurant',
          name: 'restaurant',
          component: () => import("../views/restaurant/restaurant.vue"),
        },
        {
          path: 'hotel',
          name: 'hotel',
          component: () => import("../views/hotel/hotel.vue"),
        }
      ]
    }
  ],
  // 配置滚动行为
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { x: 0, y: 0 };
    }
  }
});

export default router;
